package com.item.audrey_hepburn.factory;/*/**

 _______  _______________   _________________________  __________ ____ ___  ________ 
 \      \ \_   _____/\   \ /   /\_   _____/\______   \ \______   \    |   \/  _____/ 
 /   |   \ |    __)_  \   Y   /  |    __)_  |       _/  |    |  _/    |   /   \  ___ 
/    |    \|        \  \     /   |        \ |    |   \  |    |   \    |  /\    \_\  \
\____|__  /_______  /   \___/   /_______  / |____|_  /  |______  /______/  \______  /
        \/        \/                    \/         \/          \/                 \/ 
 
 * @Auther: WD
 * @Date: 19-5-8 21:26
 * @Description: 高铁票
 */

import com.alibaba.fastjson.JSONArray;
import com.item.audrey_hepburn.entity.db2.Ticket;

import java.util.ArrayList;
import java.util.List;

public class HighSpeed implements TicketFactory {
    @Override
    public List<Ticket> findByTypeInfo(JSONArray jsonArray) {
        List<Ticket>tickets=new ArrayList<>();
        Ticket ticket =null;
        for(int i=0;i<jsonArray.size();i++){
            String result = jsonArray.get(i).toString();
            //System.out.println(result);

            String TrainNumber = result.split("\\|")[3];
            String[] datas = result.split("\\|");
           if(TrainNumber.split("")[0].equals("G")) {

               ticket =
                       new Ticket
                               .Builder()
                               .setTRAINNUMBER(TrainNumber)
                               .setTICKETTYPE("高铁票")
                               .setSTART(datas[6])
                               .setEND(datas[7])
                               .setSTARTTIME(datas[8])
                               .setENDTIME(datas[9])
                               .setUSETIME(datas[10])
                               .setHIGHGRADESOFTBERTH(null)
                               .setORDINARYSOFTSLEEPER(null)
                               .setHARDSLEEPER(null)
                               .setSOFTSEATS(null)
                               .setHARDSEAT(null)
                               .setNOSEAT(null)
                               .setBUSINESSBLOCK(datas[32])
                               .setFIRSTCLASSSEAT(datas[31])
                               .setSECONDCLASSSEAT(datas[30])
                               .builder()
               ;
               tickets.add(ticket);
               //System.out.println("高铁："+ticket.toString());

           }
        }
        return tickets;
    }
}
